<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class image_detail_model extends Model
{
	var $url_prefix2 = 'admin/image.image.lists';
	var $url_prefix = 'admin/image.image.detail';
	var $start_segment = 3;
	var $start;
	var $msg_cache_prefix = 'msg';
	var $cache;
	var $cache_name = 'image';
	var $item_segment = 4;
	var $item;
	
	function image_detail_model()
	{
		parent::Model();
		
		global $CI;
		$start = $CI->uri->segment($this->start_segment);
		$this->start = $start?$start:0;
		
		$item = $CI->uri->segment($this->item_segment);
		$this->item = $item?$item:0;
		
		$this->cache = new Session_lite($this->cache_name);
	}
	
	function admin_id()
	{
		global $CI;
		$a = $CI->session->userdata('admin_auth_logged');
		return $a['admin_id'];
	}
	
	function hasImage()
	{
		$q = $this->db->get_where(IMAGE, array(IMAGE_IMAGE_ID=>$this->item));
		return $q->num_rows()>0;
	}
	
	function maxkey()
	{
		$this->db->select_max(IMAGE_IMAGE_ID);
		$q = $this->db->get(IMAGE);
		$row = $q->row();
		return $row?($row->{IMAGE_IMAGE_ID}+1):1;
	}	
}

?>
